<!-- Generated automatically from an XML file of the same name.
     Copyright: Stephen J. Sangwine and Nicolas Le Bihan, 2008-2010.
--><html><head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
   <title>imwrite :: Functions (Quaternion Toolbox Function Reference)
</title><link rel="stylesheet" href="qtfmstyle.css" type="text/css"></head><body><h1>Quaternion Function Reference</h1><h2>imwrite</h2>
<p>Write an image file from a quaternion array.<br>(Quaternion overloading of standard MATLAB&reg; function)
</p>
<h2>Syntax</h2><p><tt>imwrite(A, filename, fmt)</tt></p>
<h2>Description</h2>
    <p>
        <tt>imwrite</tt> writes an image file from data stored in a pure
        quaternion array. It supports the same parameter profiles as the MATLAB&reg;
        function of the same name, but the first parameter must be a quaternion
        array with elements of type <tt>uint8</tt>,
        <tt>uint16</tt>, or <tt>double</tt>.
        The type of image written to the file depends on the
        quaternion data in the array <tt>A</tt>. If the quaternion data has
        components of type <tt>uint16</tt>, then 16-bit samples will be written to the
        file. In all other cases 8-bit data will be written to the file. <tt>uint8</tt> or
        <tt>uint16</tt> pixel values are not scaled - they are written directly to the
        image file. <tt>double</tt> or <tt>single</tt>
        pixel values are assumed to be in the range
        [0, 1] and are scaled by 255 before writing to the file. This behaviour
        follows from the behaviour of the overloaded MATLAB&reg; function which is used
        to write the image file after reformatting of the quaternion data into the
        form used by the MATLAB&reg; function.
    </p>
    <p>
        The function supports the same image file types as the MATLAB&reg; function.
    </p>

<h2>Examples</h2>
<pre>
&gt;&gt; imwrite(randv(128), 'random.png')
</pre>
<p>
results in the creation of an image file like the result following.
In this case, because
<tt>randv</tt> generates <tt>double</tt> quaternion data with component values
in the range [0,1], the data is automatically scaled to the integer range
[0,255] before writing to the Portable Network Graphics file.
</p>
<img src="random.png">

<h2>See Also</h2>MATLAB&reg; function: <a href="matlab:doc imwrite">imwrite</a><br>QTFM functions: <a href="imreadq.html">imreadq</a>, <a href="image.html">image</a><br>
<h4>&copy; 2008-2010 Stephen J. Sangwine and Nicolas Le Bihan</h4><p><a href="license.html">License terms.</a></p></body></html>